<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "pf_client".
 *
 * @property string $client_id
 * @property string $client_name
 * @property string $client_password
 * @property string $client_appkey
 * @property integer $add_time
 * @property integer $is_active
 * @property string $created_time
 * @property string $qqnumber
 * @property string $lastlogintime
 * @property integer $begindate
 * @property integer $enddate
 */
class Client extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%client}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['client_id'], 'required'],
            [['is_active'], 'integer'],
//            [['created_time', 'lastlogintime'], 'safe'],
            [['client_id'], 'string', 'max' => 7],
            [['client_name', 'qqnumber'], 'string', 'max' => 20],
            [['client_password', 'client_appkey'], 'string', 'max' => 8],
            [['begindate', 'enddate'], 'date', 'format' => 'php:Y-m-d'],
            ['add_time','default','value'=>time()],
            [['begindate'], 'filter', 'filter' => function(){
                return strtotime($this->begindate);
            }],
            [['enddate'], 'filter', 'filter' => function(){
                return strtotime($this->enddate);
            }],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'client_id' => 'Client ID',
            'client_name' => 'Client Name',
            'client_password' => 'Client Password',
            'client_appkey' => 'Client Appkey',
//            'add_time' => 'Add Time',
            'is_active' => 'Is Active',
//            'created_time' => 'Created Time',
            'qqnumber' => 'Qqnumber',
//            'lastlogintime' => 'Lastlogintime',
            'begindate' => 'Begindate',
            'enddate' => 'Enddate',
        ];
    }
}
